package com.example.rabbitmq.sender;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Copyright(C), 2020-2021, AmbroseCdMeng
 * FileName:    TopicSender
 * Author:      AmbroseCdMeng
 * Date:        2021/3/2 10:19
 * Description: 编写发送者。实现用接收器接收多个主题
 * History:
 * <author>     <time>      <version>       <desc>
 * 作者姓名     修改时间        版本号           描述
 */
@Component
public class TopicSender {
    @Autowired
    private AmqpTemplate amqpTemplate;

    public void send(){
        String context = "topic";
        System.out.println("Sender: " + context);
        this.amqpTemplate.convertAndSend("topicExchange", "topic.1", context);
    }

    public void send2(){
        String context = "topic 2";
        System.out.println("Sender: " + context);
        this.amqpTemplate.convertAndSend("topicExchange", "topic.a", context);
    }

    public void send3(){
        String context = "topic 3";
        System.out.println("Sender:" + context);
        this.amqpTemplate.convertAndSend("topicExchange", "topic.b", context);
    }
}
